<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>广软课室申请后台管理系统</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" th:href="@{../x-admin/css/font.css}">
    <link rel="stylesheet" th:href="@{../x-admin/css/xadmin.css}">
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script th:src="@{../x-admin/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../x-admin/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script th:src="@{https://cdn.staticfile.org/html5shiv/r29/html5.min.js}"></script>
    <script th:src="@{https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js}"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="account" name="account"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="rpassword" name="rpassword"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="update" lay-submit="" type="button" value="修改">
                    注册
                </button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            let form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(update)',
                function (data) {
                    let account = $('#account').val();
                    let password = $('#password').val();
                    let rpassword = $('#rpassword').val();
                    if (rpassword==password){
                        $.ajax({
                            url: "/admin/adminadd",
                            type: "POST",
                            data: JSON.stringify({
                                userId:0,
                                account: account,
                                password: password,
                                roleId:0,
                                status:1,
                            }),
                            contentType: "application/json;charset=UTF-8",
                            dataType: "json",
                            success: function (res) {
                                if (res > 0) {
                                    layer.alert("添加成功", {
                                            icon: 6
                                        },
                                        function () {
                                            //关闭当前frame
                                            xadmin.close();
                                            // 可以对父窗口进行刷新
                                            xadmin.father_reload();
                                        });
                                } else {
                                    layer.alert("添加失败");
                                }
                            }
                        })
                    }else {
                        layer.alert("两次密码不一致");
                    }
                    return false;
                });
        });
</script>
</html>
